package cn.rslee.java.demos.test

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object ReduceByKey {
  def main(args: Array[String]): Unit = {
    val sc = new SparkContext(new SparkConf().setAppName("ReduceByKey").setMaster("local"))
    val list = List("hadoop", "spark", "hive", "spark")
    val rdd = sc.parallelize(list)
    val pairRdd = rdd.map((_, 1)).foreach(println);
    rdd.map((_, 1)).reduceByKey(_ + _).collect.foreach(println);
  }
}